package hospital.user.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import hospital.model.user.UserInfo;
import hospital.result.Result;
import hospital.user.service.UserInfoService;
import hospital.vo.acl.UserQueryVo;
import hospital.vo.user.UserInfoQueryVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @author
 * @description:
 */
@Api("用户的后台管理接口")
@RestController
@RequestMapping("/admin/user")
public class UserAdminController {
    @Autowired
    private UserInfoService userInfoService;

    /**
     * @Author yang
     * @Description //TODO 后台分页查询用户列表
     * @Param
     * @return
     **/
    @ApiOperation("分页查询用户列表")
    @PostMapping("list/{page}/{limit}")
    public Result findAll(@PathVariable Integer page,@PathVariable Integer limit,UserInfoQueryVo queryVo){
        Page<UserInfo> userInfoPage=userInfoService.findALl(page,limit,queryVo);
        return Result.ok(userInfoPage);
    }
    
    /**
     * @Author yang
     * @Description //TODO 用户的锁定
     * @Param
     * @return 
     **/
    @ApiOperation("用户锁定")
    @GetMapping("lock/{id}/{status}")
    public Result lock(@PathVariable Long id,@PathVariable Integer status){
        userInfoService.lock(id,status);
        return Result.ok();
    }

    /**
     * @Author yang
     * @Description //TODO 查询用户详情
     * @Param
     * @return
     **/
    @ApiOperation("查询用户详情")
    @GetMapping("show/{id}")
    public Result show(@PathVariable Long id){
        Map<String,Object> map=userInfoService.show(id);
        return Result.ok(map);
    }
    
    /**
     * @Author yang
     * @Description //TODO 认证审批
     * @Param
     * @return 
     **/

    @ApiOperation("认证审批")
    @GetMapping("approval/{id}/{authStatus}")
    public Result approval(@PathVariable Long id,@PathVariable Integer authStatus){
        userInfoService.approval(id,authStatus);
        return Result.ok();
    }
}
